package cn.sendto.dbhelper;

import java.io.InputStream;
import java.util.Properties;

public class Dbproteries {
	private static String classforName = null;
	private static String driver = null;
	private static String user = null;
	private static String passWord = null;
	static {
		loads();
	}

	synchronized static public void loads() {
		if (classforName == null || driver == null || user == null || passWord == null) {
			InputStream is = Dbproteries.class.getResourceAsStream("/data.properties");
			Properties dbProps = new Properties();
			try {
				dbProps.load(is);
				classforName = dbProps.getProperty("classforName");
				driver = dbProps.getProperty("driver");
				user = dbProps.getProperty("user");
				passWord = dbProps.getProperty("passWord");
				
			} catch (Exception e) {
				System.err.println("不能读取属性文件. " + "请确保db.properties在CLASSPATH指定的路径中");
			}
		}
	}

	public static String getClassforName() {
		if (classforName == null)
			loads();
		return classforName;
	}

	public static String getDriver() {
		if (driver == null)
			loads();
		return driver;
	}

	public static String getUser() {
		if (user == null)
			loads();
		return user;
	}

	public static String getPassWord() {
		if (passWord == null)
			loads();
		return passWord;
	}
}